package com.youwu.weather.service.impl;

import com.youwu.weather.service.DataClient;
import com.youwu.weather.service.WeatherReportService;
import com.youwu.weather.vo.HeWeather6;
import com.youwu.weather.vo.WeatherResponse;
import com.youwu.weather.vo.WeatherType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WeatherReportServiceImpl implements WeatherReportService {

    @Autowired
    private DataClient dataClient;

    @Override
    public List<HeWeather6> getDataByCity(WeatherType weatherType, String city) {
        // 数据来源：天气数据api微服务提供
        WeatherResponse weather = null;
        switch (weatherType){
            case NOW:
                weather = dataClient.getCurrentWeather(city);
                break;
            case HOURLY:
                weather = dataClient.getHourlyWeather(city);
                break;
            case FORECAST:
                weather = dataClient.getForecastWeather(city);
                break;
            case LIFESTYLE:
                weather = dataClient.getLifestyleWeather(city);
                break;
        }
//        WeatherResponse weather = weatherDataClient.getCurrentWeather(city);
//        // 暂时数据写死
//        List<HeWeather6> list = new ArrayList<>();
//        HeWeather6 heWeather6 = new HeWeather6();
//        Basic basic = new Basic();
//        basic.setCid("1");
//        basic.setLocation("厦门");
//        basic.setCnty("厦门");
//        basic.setParent_city("厦门");
//        heWeather6.setBasic(basic);
//        Map<String, Object> update = new HashMap<>();
//        update.put("updateTime", new Date());
//        heWeather6.setUpdate(update);
//        heWeather6.setStatus("ok");
//        Now now = new Now();
//        now.setTmp("22");
//        now.setCloud("3级");
//        heWeather6.setNow(now);
//        list.add(heWeather6);
        return weather.getHeWeather6();
    }
}
